package com.example.java.base.hutool;

import cn.hutool.core.convert.Convert;
import cn.hutool.core.map.MapBuilder;
import cn.hutool.core.map.MapUtil;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import cn.hutool.system.SystemUtil;
import org.junit.Test;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * MapUtilTest:
 *
 * @author zhangxiaoxiang
 * @date 2021/01/20
 */
public class MapUtilTest {
    @Test
    public void test(){
        Map<String, String> map = MapUtil.builder(new HashMap<String, String>())
                .put("name", "zhang")
                .put("age", "12")
                .map();
        System.out.println("map = " + map);
        boolean empty = MapUtil.isEmpty(map);
        System.out.println("empty = " + empty);
        HashMap<String, Integer> sex = MapUtil.of("sex", 0);
        System.out.println("sex = " + sex);
        List<?> list = Convert.toList(map);
        System.out.println("list = " + list);
        String convert = Convert.convert(String.class, 12);
        System.out.println("convert = " + convert);
        Integer convert1 = Convert.convert(Integer.class, "1894564777");
        System.out.println("convert1 = " + convert1);
        JSONObject jsonObject = JSONUtil.parseObj(map);
        System.out.println("jsonObject = " + jsonObject);


        ArrayList<String> list1 = new ArrayList<>();
        list1.add("12");
        list1.add("34");
        list1.add("56");
        JSONArray objects = JSONUtil.parseArray(list1, true);


        System.out.println("objects = " + objects.get(2));

        System.out.println("SystemUtil.getJvmSpecInfo() = " + SystemUtil.getJvmSpecInfo());


    }
}
